home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / pcc / v05n01 / in_touch.bas < prev   
Encoding:
BASIC Source File  |  1991-12-11  |  4.5 KB  |  131 lines

  1. ' IN-TOUCH.BAS
  2. ' A flat-file database that allows you to enter the names and
  3. ' phone numbers of business contacts and search for them, then
  4. ' dial their number using your modem and attached telephone.
  5.  
  6. DECLARE SUB AddName ()
  7. DECLARE SUB SearchName ()
  8. DECLARE SUB DialNumber ()
  9. OPTION BASE 1
  10. DIM SHARED Name$(4, 19)       ' Array to hold each name and phone number
  11. DIM SHARED NumNames%          ' Number of names found in database
  12. DIM SHARED HomeAC$            ' Your home area code
  13. DIM SHARED filename$          ' Name of contacts database file
  14.  
  15. filename$ = "CONTACTS.TXT"
  16.  
  17. HomeAC$ = "206"               ' Local area code (change when traveling)
  18.  
  19. ' Display the main menu
  20. MainMenu:
  21. CLS : LOCATE 7, 25: PRINT "BUSINESS CONTACTS DATABASE"
  22. LOCATE 8, 25: PRINT "AND AUTODIALER"
  23. LOCATE 11, 25: PRINT "------------ MAIN MENU -------------"
  24. LOCATE 14, 25: PRINT "1. ADD a name to the database"
  25. LOCATE 16, 25: PRINT "2. SEARCH for a name in the database"
  26. LOCATE 18, 25: PRINT "3. QUIT this program"
  27. LOCATE 21, 25: PRINT "Please enter 1, 2, or 3"
  28.  
  29. ' Get the user's choice
  30. DO: choice$ = INKEY$
  31. LOOP UNTIL choice$ = "1" OR choice$ = "2" OR choice$ = "3"
  32.  
  33. SELECT CASE choice$
  34.     CASE "1"        ' Add a name to the database
  35.         AddName
  36.     CASE "2"        ' Search for a name in the database
  37.         SearchName
  38.     CASE "3"        ' Quit the program and return to DOS
  39.         SYSTEM
  40. END SELECT
  41. GOTO MainMenu:
  42.  
  43. SUB AddName
  44.     OPEN filename$ FOR APPEND AS #1
  45.     WHILE UCASE$(last$) <> "END"
  46.         CLS : LOCATE 11, 25: PRINT "ADD a name to the database"
  47.         LOCATE 12, 25: PRINT "(To stop, enter END as a last name)"
  48.         LOCATE 14, 25: INPUT "Last name:"; last$
  49.         IF UCASE$(last$) <> "END" THEN
  50.             LOCATE 16, 24: INPUT "First name:"; first$
  51.             LOCATE 18, 25: INPUT "Area code:"; area$
  52.             LOCATE 20, 22: INPUT "Phone number:"; phone$
  53.             WRITE #1, last$, first$, area$, phone$: CLS
  54.         END IF
  55.     WEND
  56.     CLOSE #1: last$ = ""
  57.  
  58. END SUB
  59.  
  60. SUB DialNumber
  61.     LOCATE 3, 15: PRINT "Make sure your modem is turned on!"
  62.     LOCATE , 15: PRINT "You must pick up the handset by the second ring."
  63. GetInput:
  64.     LOCATE 7, 15: PRINT "(Enter 0 to cancel and return to main menu.)"
  65.     LOCATE 6, 66: PRINT "  ": LOCATE 6, 15
  66.     INPUT "Enter the number of the person you'd like to call: ", choice%
  67.  
  68.     IF choice% < 0 OR choice% > NumNames% THEN
  69.         LOCATE 5, 11
  70.         PRINT "--->Please enter a number between 0 and"; NumNames%
  71.         GOTO GetInput
  72.     END IF
  73.  
  74.     IF choice% = 0 THEN GOTO SkipIt
  75.     CLS : LOCATE 3, 15: PRINT "Dialing: ";
  76.     PRINT Name$(2, choice%); " "; Name$(1, choice%); "  ";
  77.     IF Name$(3, choice%) = HomeAC$ THEN Name$(3, choice%) = ""
  78.     IF Name$(3, choice%) <> "" THEN
  79.         PhoneNum$ = "1," + Name$(3, choice%)
  80.         PRINT "("; Name$(3, choice%); ")-";
  81.     END IF
  82.     PRINT Name$(4, choice%)
  83.                                                   
  84.     ' If needed, insert routine to prompt the user to dial 1 first here
  85.  
  86.     PhoneNum$ = PhoneNum$ + Name$(4, choice%)
  87.     OPEN "com1:1200,e,7,1,BIN,CD0,CS0,DS0,OP0" FOR RANDOM AS #2
  88.     PRINT #2, "ATS7=9DT", PhoneNum$
  89.     LOCATE 5, 15: PRINT "Press ESC at any time to cancel."
  90.     LOCATE 7, 15: PRINT "Pick up the phone before the second ring."
  91.     LOCATE 9, 15
  92.     PRINT "After picking up the phone, press any key to continue."
  93.     DO: LOOP UNTIL INKEY$ <> ""
  94.    
  95.     PRINT #2, "ATS7=30": CLOSE #2
  96.    
  97. SkipIt:
  98. END SUB
  99.  
  100. SUB SearchName
  101.     form$ = "\            \ \       \  (\ \)-\       \"
  102.     NumNames% = 0: search$ = "": hit% = 0
  103.     OPEN filename$ FOR INPUT AS #1
  104.     CLS : LOCATE 4, 15: PRINT "SEARCH for a name in the database"
  105.     LOCATE 7, 15: INPUT "Name to search for:"; search$: PRINT
  106.            
  107.     DO WHILE (NOT EOF(1))
  108.         INPUT #1, last$, first$, area$, phone$
  109.         test$ = UCASE$(search$)
  110.         IF UCASE$(last$) = test$ OR UCASE$(first$) = test$ THEN
  111.             hit% = 1: NumNames% = NumNames% + 1
  112.             Name$(1, NumNames%) = last$: Name$(2, NumNames%) = first$
  113.             Name$(3, NumNames%) = area$: Name$(4, NumNames%) = phone$
  114.             LOCATE , 15: PRINT NumNames%; "- ";
  115.             PRINT USING form$; last$; first$; area$; phone$
  116.     END IF
  117. LOOP
  118.  
  119. IF hit% <> 0 THEN DialNumber
  120.  
  121. IF hit% = 0 THEN
  122.     LOCATE , 15: PRINT "No match found for "; search$
  123.     LOCATE , 15: PRINT "Press any key to continue"
  124.     DO WHILE INKEY$ = "": LOOP
  125. END IF
  126.  
  127. CLOSE #1
  128.                
  129. END SUB
  130.  
  131.